import scrollOpt from '../base/scrollOptimize'
import { TeamOrder } from '../../config/play_def'
import { UI_Listen, SKILLKARDBG, UI_Layer } from '../../config/ui_def'
import { Sdk_Platform, WX_AD_CONFIG, VIVO_AD_CONFIG, OPPO_AD_CONFIG, Ad_Type } from '../../frame/constants';
cc.Class({
    extends: scrollOpt,

    properties: {
        card_team_node: cc.Node,
        descript_node: cc.Node,
        descript_lab: cc.Label,

        use_btn: cc.Node,
        quit_btn: cc.Node,
        replace_btn: cc.Node,
        unload_btn: cc.Node,
        mergeContent: cc.Node,
        mergeNode: cc.Node,
        merge_btn: cc.Node,
        title_lab: cc.Label,
        haveGold_lab: cc.Label,
        bottomNode: cc.Node,
        mergeadNode: cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    initPage() {
        if (!he.pool.getPool('skillItem')) {
            he.pool.createPoolSync('skillItem', 5, cc.Prefab, 'uimod/skillItem')
        }

        let addNum = 5 - this.card_team_node.childrenCount
        let reward_prefab = he.load.get("uimod/skillItem")
        for (let i = 0; i < addNum; i++) {
            let reward_node = cc.instantiate(reward_prefab)
            reward_node.getComponent('skillItem').hideItem()
            this.card_team_node.addChild(reward_node)
        }
        if (!he.pool.getPool('mergeItem')) {
            he.pool.createPoolSync('mergeItem', 5, cc.Prefab, 'uimod/mergeItem')
        }

    },

    updatePage() {
        // this.card_team_node.children.forEach(element => {
        //     element.getComponent('skillItem').hideItem()
        // });
        this.adSwitch(true)
        this.chooseTeam = false
        this.chooseBag = false
        this.teamItemIndex = -1
        this.bagItemIndex = -1
        this.bagItemInfo = null
        this.teamItemInfo = null
        gg.eventManager.on('card', this.listenClient, this)
        this.scrollInit()
        this.openListen()
        this.teambagInit()
        this.teamInit()
        this.getMoney()
        this.stateCheck()
        this.showBtns()
        this.unLoadSkillInfo()
        this.mergeNode.active = false
        let guideList = he.local.getJson('guideList', 'user')
        if (!guideList) {
            return
        } else {
            if (!guideList[4]) {
                //新手引导
                guideList[4] = 1
                gg.data.pause = true
                gg.eventManager.emit('newGuide', { index: 4 })
                he.local.setJson('guideList', guideList, 'user')
            }
        }

    },

    adSwitch(status) {
        if (status) {
            switch (common.sdk_env) {
                case Sdk_Platform.WECHAT:

                    break
                case Sdk_Platform.VIVO:
                    // he.ad.loadInterstitial()
                    let guideList1 = he.local.getJson('guideList', 'user')
                    if (!guideList1[6]) {
                        return
                    }
                    let num3 = Math.ceil(Math.random() * 10)//20 的几率弹出
                    if (num3 < 2) {
                        gg.uiManager.addPage(UI_Layer.Click, {
                            name: 'randomCardPage',
                            cover: true,
                        })
                        break
                    }
                    break
                case Sdk_Platform.OPPO:
                    let guideList = he.local.getJson('guideList', 'user')
                    if (!guideList[6]) {
                        return
                    }
                    gg.uiManager.addPage(UI_Layer.Msg, {
                        name: 'chayeAdFakeOPPO',
                        isShowAd: true,
                        isShowBanner: false,
                        adIndex: 1,
                        position: cc.Vec2(0, -470)
                    })
                    let num = Math.ceil(Math.random() * 10)//20 的几率弹出
                    if (num < 2) {
                        gg.uiManager.addPage(UI_Layer.Click, {
                            name: 'randomCardPage',
                            cover: true,
                        })
                        break
                    }
                case Sdk_Platform.UC:
                    let guideList3 = he.local.getJson('guideList', 'user')
                    if (!guideList3[6]) {
                        return
                    }
                    let num4 = Math.ceil(Math.random() * 10)

                    he.ad.showInterstitialAd()
                    break

                case Sdk_Platform.HUAWEI:
                    gg.uiManager.addPage(UI_Layer.Msg, {
                        name: 'hwAdPage',
                        cover: false,
                        isShowAd: true,
                        adType: Ad_Type.INSERT,
                        position: 0
                    })
                    break
                default:
                    let guideList2 = he.local.getJson('guideList', 'user')
                    if (!guideList2[6]) {
                        return
                    }

                    let num2 = Math.ceil(Math.random() * 10)//20 的几率弹出
                    if (num2 < 2) {
                        gg.uiManager.addPage(UI_Layer.Click, {
                            name: 'randomCardPage',
                            cover: true,
                        })
                        break
                    }
                    break

            }
        } else {
            //  关掉广告
            switch (common.sdk_env) {
                case Sdk_Platform.OPPO:
                    gg.uiManager.closePage(UI_Layer.Msg, 'chayeAdFakeOPPO')
                    break
                case Sdk_Platform.UC:
                    he.ad.closeBanner()
                    break

                case Sdk_Platform.HUAWEI:
                    if (gg.uiManager.getPage(UI_Layer.Msg, 'hwAdPage')) {
                        gg.uiManager.closePage(UI_Layer.Msg, 'hwAdPage')
                    }
                    break
            }
        }
    },

    getMoney() {
        let money = he.local.getJson('coin', 'user')
        // console.log(money)
        if (money) {
            this.haveGold_lab.string = money
        } else {
            this.haveGold_lab.string = 0
        }

    },

    listenClient(code, param, arg) {
        // console.log(code.type)
        switch (code.type) {
            case UI_Listen.SKILL_TEAMCARD:
                this.teamCardServer(null, code.index, code.info)

                break
            case UI_Listen.SKILL_BAGCARD:
                if (code.index >= 0) {
                    // console.log(this.bagItemIndex ,"   ",code.index)
                    if (this.bagItemIndex == code.index) {
                        this.content.children[this.bagItemIndex].getComponent('skillItem').hideLight()
                        this.chooseBag = false
                        this.bagItemIndex = -1
                        // this.bagItemIndex=null
                        this.stateCheck()
                        this.showBtns()
                        if (this.chooseTeam) {
                            this.showSkillInfo(this.card_team_node.children[this.teamItemIndex].getComponent('skillItem').info)
                        }
                        else (
                            this.unLoadSkillInfo()
                        )
                        return
                    }
                    this.bagItemInfo = code.info
                    if (this.bagItemIndex != -1) {
                        this.content.children[this.bagItemIndex].getComponent('skillItem').hideLight()
                    }
                    this.bagItemIndex = code.index
                    this.content.children[code.index].getComponent('skillItem').showLight()
                    this.showSkillInfo(code.info)
                    this.chooseBag = true
                    this.stateCheck()
                    this.showBtns()
                }
                break
            case UI_Listen.SKILL_UPDATEPAGE:
                this.mergeNode.active = false
                this.teamInit()
                this.teambagInit()
                this.getMoney()
                this.teamItemInfo = null
                this.teamItemIndex = -1
                this.chooseTeam = false
                this.bagItemInfo = null
                this.bagItemIndex = -1
                this.chooseBag = false
                this.stateCheck()
                this.showBtns()
                this.unLoadSkillInfo()
                break
            case "TEAM"://选中下面的一个
                this.FreeUse(code.index)
                break
            case "BAG":
                this.FreeUnload()
                break
            case UI_Listen.SKILL_UPDATEMERGE:
                this.mergebtnServer()
                this.teambagInit()
                this.teamInit()
                this.getMoney()
                break
            case UI_Listen.SKILL_ADDCARD:
                this.teambagInit()
                this.teamInit()
                break
        }



    },

    closeUI() {
        for (let i = (this.content.children.length); i > 0; i--) {
            this.content.children[i - 1].getComponent('skillItem').hideItem()
            he.pool.putElement('skillItem', this.content.children[i - 1])
        }
        this.adSwitch(false)
        this.node.targetOff(this)
        this.closeListen()
    },

    teamInit() {
        this.card_team_node.children.forEach(element => {
            element.getComponent('skillItem').hideItem()
        });
        let card_team = he.local.getJson('card_team', 'user')
        for (let i = 0; i < this.card_team_node.children.length; i++) {
            let script = this.card_team_node.children[i].getComponent('skillItem')
            script.infoInit(null, i, SKILLKARDBG.TEAM)
        }

        for (let j = 0; j < card_team.length; j++) {
            let index = this.getIndex(card_team[j].index)
            let script = this.card_team_node.children[index].getComponent('skillItem')
            script.infoInit(card_team[j], index, SKILLKARDBG.TEAM)
        }
    },
    //技能出战对象
    teamCardInit(index, info) {
        // console.log("teamCardInit")
        this.card_team_node.children[index]
        if (!info) {
            let name = `skill_down_${index + 1}`
            this.card_team_node.children[index].getChildByName('icon').getComponent(cc.Sprite).spriteFrame = he.load.get('fightMain', cc.SpriteAtlas, 'plist').getSpriteFrame(name)
        }
    },
    //技能出战对象  选中亮光
    teamCardHighLight(index) {
        // console.log("teamCardHighLight")
        for (let i = 0; i < 5; i++) {
            this.card_team_node.children[i].getChildByName('light').active = false
        }
        this.card_team_node.children[index].getChildByName('light').active = true
    },

    getIndex(num) {
        // console.log("getIndex")
        for (let i = 0; i < TeamOrder.length; i++) {
            if (TeamOrder[i] == num) {
                return i
            }
        }
    },
    //选择card出战队列item
    teamCardServer(event, param, info) {
        //  console.log("teamCardServer"+param)
        if (!this.card_team_node) return
        let isHave = false
        let card_team = he.local.getJson('card_team', 'user')
        for (let j = 0; j < card_team.length; j++) {
            if (card_team[j].index == TeamOrder[param]) {
                isHave = true
                this.teamItemInfo = card_team[j]
                break
            }
        }
        if (!isHave) {
            //选中的地方没有item 直接返回
            return
        }
        for (let i = 0; i < this.card_team_node.children.length; i++) {
            this.card_team_node.children[i].getChildByName('light').active = false
        }
        if (this.teamItemIndex == param) {

            //重复选择  ，取消当前选择
            this.teamItemIndex = -1
            this.chooseTeam = false
            //检查其他的设置
            this.stateCheck()
            this.showBtns()
            if (this.chooseBag) {
                this.showSkillInfo(this.content.children[this.bagItemIndex].getComponent('skillItem').info)
            }
            else {
                this.unLoadSkillInfo()
            }
            return

        } else {
            // this.card_team_node.children[this.teamItemIndex].getChildByName('light').active = false
            this.card_team_node.children[param].getChildByName('light').active = true
            this.teamItemIndex = param
            this.chooseTeam = true
        }

        this.stateCheck()
        this.showBtns()
        this.showSkillInfo(info)
    },



    // ===============================================================背包逻辑===================================
    //背包初始化
    teambagInit() {
        // console.log("this.content.children.length"+this.content.children.length)
        for (let i = (this.content.children.length); i > 0; i--) {
            this.content.children[i - 1].getComponent('skillItem').hideItem()
            he.pool.putElement('skillItem', this.content.children[i - 1])
        }
        let cardBag = he.local.getJson('card', 'user')
        let bagNum = he.local.getJson('bagNum', 'user') || 20
        bagNum = bagNum >= cardBag.length ? bagNum : cardBag.length
        for (let i = 0; i < bagNum; i++) {
            let pre = he.pool.getElement('skillItem')
            pre.parent = this.content
            pre.getComponent('skillItem').hideItem()
        }
        // console.log(cardBag.length)
        if (cardBag && cardBag.length > 0) {
            for (let j = 0; j < cardBag.length; j++) {
                this.bagItemInit(j, cardBag[j])
                // if (j == 0) {
                //     let spt = this.content.children[j].getComponent('skillItem')
                //     // spt.infoInit(cardBag[j],j)/
                //     spt.showLight()
                //     spt.clickServer()
                //     this.bagItemIndex = 0
                //     this.bagItemInfo = cardBag[j]
                //     this.gameState = UI_Listen.SKILL_ONLY_BAG
                // }
            }
        } else {
            this.chooseBag = false
            this.gameState = UI_Listen.SKILL_NONE
        }
        this.showBtns()
    },

    updateBag() {
        // console.log("updateBag")
        let cardBag = he.local.getJson('card', 'user')

        for (let i = 0; i < this.content.children.length; i++) {
            this.content.children[i].getComponent('skillItem').hideItem()
            this.content.children[i].getComponent('skillItem').hideLight()
        }
        // console.log(cardBag)
        if (cardBag && cardBag.length > 0) {
            for (let j = 0; j < cardBag.length; j++) {
                this.bagItemInit(j, cardBag[j])
            }
        }
    },

    bagItemInit(index, info) {
        // console.log("bagItemInit")
        //记得添加数据
        this.content.children[index].getComponent('skillItem').infoInit(info, index)
        // this.content.children[index].getComponent('skillItem').showItem()
    },
    //============================================================================分割线==========================================================
    // 技能信息展示
    showSkillInfo(info) {

        if (info) {
            let iconName = ``
            // this.descript_icon.spriteFrame = he.load.get('url', cc.SpriteAtlas).getSpriteFrame(iconName)
            this.descript_node.getComponent('skillItem').infoInit(info)
            let cardinfo = he.db.getDataByArgs("Card", { cardId: info.id, level: info.lv })
            if (cardinfo) {
                this.descript_lab.string = `${cardinfo.description}`//待补充
                this.title_lab.string = `${cardinfo.name}`
            }

        }
    },
    unLoadSkillInfo() {
        if (this.gameState == UI_Listen.SKILL_NONE) {
            this.descript_node.getComponent('skillItem').infoInit(null)
            this.descript_lab.string = ""
            this.title_lab.string = "请选择道具"
        }

    },
    //检查阶段
    stateCheck() {
        if (this.chooseTeam && !this.chooseBag) {
            this.gameState = UI_Listen.SKILL_ONLY_TEAM
        } else if (!this.chooseTeam && this.chooseBag) {
            this.gameState = UI_Listen.SKILL_ONLY_BAG
        } else if (this.chooseTeam && this.chooseBag) {
            this.gameState = UI_Listen.SKILL_BAG_TEAM
        } else if (!this.chooseTeam && !this.chooseBag) {
            this.gameState = UI_Listen.SKILL_NONE
        }
    },

    //显示使用按钮
    showBtns() {
        switch (this.gameState) {
            case UI_Listen.SKILL_ONLY_TEAM:
                this.quit_btn.active = false
                this.use_btn.active = false
                this.replace_btn.active = false
                this.unload_btn.active = true
                this.merge_btn.active = false
                break
            case UI_Listen.SKILL_ONLY_BAG:
                this.quit_btn.active = false
                this.use_btn.active = true
                this.replace_btn.active = false
                this.unload_btn.active = false
                this.merge_btn.active = true
                break
            case UI_Listen.SKILL_BAG_TEAM:
                this.quit_btn.active = false
                this.use_btn.active = false
                this.replace_btn.active = true
                this.unload_btn.active = false
                this.merge_btn.active = false
                break
            case UI_Listen.SKILL_NONE:
                this.quit_btn.active = false
                this.use_btn.active = false
                this.replace_btn.active = false
                this.unload_btn.active = false
                this.merge_btn.active = false
                break
        }
    },


    //点击上面的teamcard Item后 会显示取消按钮，即取消所选择的
    quitBtnServer() {
        // console.log("quitBtnServer")
        for (let i = 0; i < this.card_team_node.children.length; i++) {
            this.card_team_node.children[i].getChildByName('light').active = false
        }

    },
    //卸下按钮
    unloadBtnServer() {
        // console.log("unloadBtnServer")
        let card_team = he.local.getJson('card_team', 'user')
        let cardBag = he.local.getJson('card', 'user')

        for (let j = 0; j < card_team.length; j++) {
            if (card_team[j].id == this.teamItemInfo.id && card_team[j].lv == this.teamItemInfo.lv && card_team[j].index == this.teamItemInfo.index) {
                card_team.splice(j, 1)
                break
            }
        }
        he.local.setJson('card_team', card_team, 'user')
        cardBag.push({ id: this.teamItemInfo.id, lv: this.teamItemInfo.lv })
        he.local.setJson('card', cardBag, 'user')
        this.bagItemIndex = -1
        this.teamItemIndex = -1
        this.chooseTeam = false
        this.stateCheck()
        this.showBtns()
        this.quitBtnServer()
        this.unLoadSkillInfo()
        this.teamInit()
        this.updateBag()

    },
    FreeUnload() {
        if (this.gameState == UI_Listen.SKILL_ONLY_TEAM) {
            this.unloadBtnServer()
        }
    },


    //出战按钮方法
    useBtnServer() {
        if (this.gameState == UI_Listen.SKILL_ONLY_BAG) {
            let card_team = he.local.getJson('card_team', 'user')
            let cardBag = he.local.getJson('card', 'user')
            let teamGrp = []
            let oriGrp = [1, 2, 3, 4, 5]
            for (let i = 0; i < card_team.length; i++) {
                teamGrp.push(card_team[i].index)
            }
            let diffGrp = this.getArrDifference(teamGrp, oriGrp)
            // console.log(diffGrp)
            let newIndex = -1
            if (diffGrp && diffGrp.length > 0) {
                for (let j = 0; j < TeamOrder.length; j++) {
                    if (TeamOrder[j] == diffGrp[0]) {
                        newIndex = j
                        break
                    }
                }
            } else {
                gg.uiManager.addTip('出战队伍已满')
                return
            }
            let newTeamInfo = { id: this.bagItemInfo.id, lv: this.bagItemInfo.lv, index: diffGrp[0] }
            card_team.push(newTeamInfo)
            he.local.setJson('card_team', card_team, 'user')

            for (let k = 0; k < cardBag.length; k++) {
                if (cardBag[k].id == this.bagItemInfo.id && cardBag[k].lv == this.bagItemInfo.lv) {
                    cardBag.splice(k, 1)
                    break
                }
            }
            he.local.setJson('card', cardBag, 'user')
            this.chooseBag = false
            this.chooseTeam = false
            this.bagItemIndex = -1
            this.teamItemIndex = -1
            this.stateCheck()
            this.showBtns()
            this.teamInit()
            this.updateBag()

        }
    },
    //自由战斗
    FreeUse(index) {
        let arr = [5, 3, 1, 2, 4]
        let intA = arr[index]
        let card_team = he.local.getJson('card_team', 'user')
        let cardBag = he.local.getJson('card', 'user')
        if (this.gameState == UI_Listen.SKILL_ONLY_BAG) {

            let newTeamInfo = { id: this.bagItemInfo.id, lv: this.bagItemInfo.lv, index: intA }
            card_team.push(newTeamInfo)
            he.local.setJson('card_team', card_team, 'user')

            for (let k = 0; k < cardBag.length; k++) {
                if (cardBag[k].id == this.bagItemInfo.id && cardBag[k].lv == this.bagItemInfo.lv) {
                    cardBag.splice(k, 1)
                    break
                }
            }
            he.local.setJson('card', cardBag, 'user')
            this.chooseBag = false
            this.bagItemIndex = -1
        }
        if (this.gameState == UI_Listen.SKILL_ONLY_TEAM) {
            for (let j = 0; j < card_team.length; j++) {
                if (card_team[j].id == this.teamItemInfo.id && card_team[j].lv == this.teamItemInfo.lv && card_team[j].index == this.teamItemInfo.index) {
                    card_team.splice(j, 1)
                    break
                }
            }
            let newTeamInfo = { id: this.teamItemInfo.id, lv: this.teamItemInfo.lv, index: intA }
            card_team.push(newTeamInfo)
            he.local.setJson('card_team', card_team, 'user')
            he.local.setJson('card', cardBag, 'user')
            this.teamItemIndex = -1
            this.chooseTeam = false
        }

        this.stateCheck()
        this.showBtns()
        this.quitBtnServer()
        this.unLoadSkillInfo()
        this.teamInit()
        this.updateBag()
    },
    //返回两个数组中不同的元素
    getArrDifference(arr1, arr2) {
        return arr1.concat(arr2).filter(function (v, i, arr) {
            return arr.indexOf(v) === arr.lastIndexOf(v);
        });
    },
    //替换按钮方法
    replaceBtnServer() {
        if (this.gameState == UI_Listen.SKILL_BAG_TEAM) {
            let card_team = he.local.getJson('card_team', 'user')
            let cardBag = he.local.getJson('card', 'user')
            for (let i = 0; i < cardBag.length; i++) {
                if (cardBag[i].id == this.bagItemInfo.id && cardBag[i].lv == this.bagItemInfo.lv) {
                    cardBag.splice(i, 1)
                    break
                }
            }
            cardBag.push({ id: this.teamItemInfo.id, lv: this.teamItemInfo.lv })
            he.local.setJson('card', cardBag, 'user')


            for (let j = 0; j < card_team.length; j++) {
                if (card_team[j].id == this.teamItemInfo.id && card_team[j].lv == this.teamItemInfo.lv && card_team[j].index == this.teamItemInfo.index) {
                    card_team.splice(j, 1)
                    break
                }
            }
            card_team.push({ id: this.bagItemInfo.id, lv: this.bagItemInfo.lv, index: this.teamItemInfo.index })
            he.local.setJson('card_team', card_team, 'user')
            this.chooseBag = false
            this.chooseTeam = false
            this.bagItemIndex = -1
            this.teamItemIndex = -1

            this.stateCheck()
            this.showBtns()
            this.quitBtnServer()
            this.unLoadSkillInfo()
            this.teamInit()
            this.updateBag()

        }
    },
    //合成按钮
    mergebtnServer() {
        this.mergeNode.active = true
        gg.uiManager.closePage(UI_Layer.Msg, 'chayeAdFakeOPPO')
        gg.uiManager.addPage(UI_Layer.Msg, {
            name: 'chayeAdFakeOPPO',
            isShowAd: true,
            isShowBanner: false,
            adIndex: 0,
            position: cc.Vec2(0, -400)
        })
        this.mergeInit()
    },


    //合成页面初始化
    mergeInit() {
        this.clearMerge()
        let skillGrp = he.db.getTable('Card')
        let itemInfo = he.db.getDataByArgs('Item', { icon: this.bagItemInfo.id, rarity: this.bagItemInfo.lv })
        // if(this.teamItemInfo){
        //     itemInfo = he.db.getDataByArgs('Item', { icon: this.teamItemInfo.id, rarity: this.teamItemInfo.lv })
        // }
        // else if(this.bagItemInfo){
        //    itemInfo = he.db.getDataByArgs('Item', { icon: this.bagItemInfo.id, rarity: this.bagItemInfo.lv })
        // }

        if (itemInfo) {
            let str = `${itemInfo.icon}_${this.bagItemInfo.lv}`
            // if(this.teamItemInfo){
            //     str = `${itemInfo.icon}_${this.teamItemInfo.lv}`
            // }
            // else if(this.bagItemInfo){
            //     str = `${itemInfo.icon}_${this.bagItemInfo.lv}`
            // }
            // let str = `${itemInfo.icon}_${this.bagItemInfo.lv}`
            // let str = `${this.bagItemInfo.id}_${this.bagItemInfo.lv}`
            let grp = []
            if (skillGrp && skillGrp.length > 0) {
                for (let i = 0; i < skillGrp.length; i++) {
                    if (skillGrp[i].merge) {
                        if (skillGrp[i].merge.indexOf(str) != -1) {
                            grp.push(skillGrp[i])
                        }
                    }
                }
                if (grp && grp.length > 0) {
                    this.mergeNode.active = true
                    for (let j = 0; j < grp.length; j++) {
                        let pre = he.pool.getElement('mergeItem')
                        pre.parent = this.mergeContent
                        pre.getComponent('mergeItem').init(grp[j])
                        // pre.getComponent('mergeItem').hideLight()
                    }
                } else {
                    this.mergeNode.active = false
                    gg.uiManager.addTip('无上阶合成路径')
                }
            }
        } else {
            this.mergeNode.active = false
            gg.uiManager.addTip('未找到相应数据')
        }

    },

    clearMerge() {
        for (let i = (this.mergeContent.children.length); i > 0; i--) {
            // this.putToPool(this.content.children[i - 1])
            he.pool.putElement('mergeItem', this.mergeContent.children[i - 1])
        }
    },

    closeMerge() {
        this.mergeNode.active = false
        if (this.teamItemInfo) {
            if (this.teamItemIndex != -1) {
                this.card_team_node.children[this.teamItemIndex].getComponent('skillItem').hideLight()
            }
        }
        else if (this.bagItemInfo) {
            // console.log(this.bagItemIndex+"this.bagItemIndex")
            if (this.bagItemIndex != -1) {
                this.content.children[this.bagItemIndex].getComponent('skillItem').hideLight()
            }
        }

        gg.uiManager.closePage(UI_Layer.Msg, 'chayeAdFakeOPPO')
        this.teamItemInfo = null
        this.teamItemIndex = -1
        this.chooseTeam = false
        this.bagItemInfo = null
        this.bagItemIndex = -1
        this.chooseBag = false
        this.stateCheck()
        this.showBtns()
        this.unLoadSkillInfo()
    },

});
